package com.handinfo.uimenu.window;

import javax.microedition.lcdui.Graphics;

import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.GameManager;
import com.handinfo.uimenu.UIAbstractWindow;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIPopmenu;
import com.handinfo.uimenu.UIWindowFactory;

/**
 * 入口兼拍卖说明类
 * @author venizeng
 * 
 */
public class UIAuction extends UIAbstractWindow
{

	public UIAuction(int id)
	{
		super(id);
	}

	/**
	 * Npc 入口
	 */
	public static final void openMenu()
	{
		final UIPopmenu popmenu = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
		popmenu.setPopmenus(new String[] { "我要购买", "我要出售","当前出售","返回"});
		popmenu.setCentre();
		popmenu.addListener(new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					int index = popmenu.getCurrentIndex();
					switch (index) {
						case 0:
							UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_AUCTION_SEARCH);
							break;
						case 1:
							GameManager.getInstance().m_game_message.sendAuctionOpenSail();
//							UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_AUCTION_SAIL);
							break;
						case 2:
							GameManager.getInstance().m_game_message.sendAuctionReSearchSelf(GameManager.getInstance().m_role.m_name) ;
							break;
						case 3:
							break;
					}
					UIManager.getInstance().removeWindow(popmenu);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(popmenu);
				}
			}
		});
	}

	protected void keyLogic()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
		}
	}

	protected void paintContent(Graphics g)
	{

	}
}
